<template>
  <div>
    <LoadingView ref="loadingRef"></LoadingView>
  </div>
</template>
  
<script>
import LoadingView from './loadingView.vue';
import userApi from "@/server/user/user.js";

export default {
  name: "Login",
  components: { LoadingView },
  data() {
    return {
    };
  },
  computed: {
  },
  async mounted() {
    const tokenMd5 = this.$route.query.tokenMd5;
    if (tokenMd5) {
      const result = await userApi.getTokenMd({ tokenMd5 });
      if (!result.isOk) {
        this.$notify('登录失败');
        this.$refs.loadingRef.show();
        return;
      }
      localStorage.setItem("token", result.data.token);
      this.$store.commit("user/login", result.data.loginSysUserVo);
      this.$refs.loadingRef.show();
    } else {
      // this.login()
      this.$refs.loadingRef.show();
    }
    
  },
  methods: {
    async login() {
      const result = await userApi.login({
        userName: '18739565772',
        password: '123456',
      });
      // const result = await userApi.login({
      //   userName: '17706341278',
      //   password: '123456',
      // });
      if (!result.isOk) {
        this.$notify('登录失败')
        this.$refs.loadingRef.show();
        return;
      }


      localStorage.setItem("token", result.data.token);

      this.$store.commit("user/login", result.data.loginSysUserVo);
      this.$refs.loadingRef.show();
    },
  },
};
</script>
  
  <style scoped>
</style>
  